//
//  ViewController.swift
//  metro-calc
//
//  Created by 安爹的Mac on 16/3/20.
//  Copyright © 2016年 安爹的苹果机. All rights reserved.
//

import UIKit
import AVFoundation //引入媒体库

class ViewController: UIViewController {
    @IBOutlet weak var outputLbl: UILabel!
    @IBOutlet weak var clearBtn: UIButton!
    var btnSound: AVAudioPlayer!
    var runningNumber = ""  //缓存数字字符串
    var leftNumber = ""  //缓存首个数字字符串
    var rightNumber = ""  //缓存第二个输入的数字
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //定义按键声音的基本属性
        let path = NSBundle.mainBundle().pathForResource("btn", ofType: "wav")
        let soundUrl = NSURL(fileURLWithPath: path!)
        do{
            try btnSound = AVAudioPlayer(contentsOfURL: soundUrl)
            btnSound.prepareToPlay()
        } catch let err as NSError{
            print(err.debugDescription)
        }
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    //定义按键后播放声音，需将每一个按键动作绑定到这个方法上
    @IBAction func numberPressed(btn: UIButton!){
        btnSound.play()
    }

}

